﻿using System;
using System.IO;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using YJKDataBase;

namespace YJKArchiFormat
{
	public class DbStandardRoom
	{
		public DbStandardRoom(string roomName, string fileName)
		{
			this.DbObject = new DbObject();
			this.DbObject.Name = roomName;
			this.DbObject.Image = Resource1._null;
			this.File = new FileInfo(fileName);
		}

		public DbStandardRoom(DbObject dbObject)
		{
			this.DbObject = new DbObject();
			this.DbObject = dbObject;
		}

		public Document Open(Autodesk.Revit.ApplicationServices.Application app)
		{
			return app.OpenDocumentFile(this.DbObject.GetObjectFile("rvt").FullName);
		}

		public static void CloseAndRemoveTempFile(Autodesk.Revit.DB.Document doc)
		{
			FileSystemInfo fileSystemInfo = new FileInfo(doc.PathName);
			doc.Close(false);
			fileSystemInfo.Delete();
		}

		public DbObject DbObject;

		public FileInfo File;
	}
}
